#ifndef TEMPLATE_QT_MAINWINDOW_H
#define TEMPLATE_QT_MAINWINDOW_H
#include <QMainWindow>
#include<QSqlDatabase>


class QSqlTableModel;

QT_BEGIN_NAMESPACE
namespace Ui
{
class MainWindow;
}
QT_END_NAMESPACE


class MainWindow : public QMainWindow
{
Q_OBJECT

public:
	explicit MainWindow(QWidget *parent = nullptr);
	~MainWindow() override;
private slots:
	void on_actNewTem_triggered();
	void on_comboBox_currentIndexChanged(int index);
	void on_actOpen_triggered();
	void on_pbtnCommit_clicked();
	void on_pbtnRevert_clicked();
	void on_actInsert_triggered();
	void on_actDel_triggered();
private:
	bool createDatabase(const QString& path);
	bool openDB(const QString& path);//打开db
	void initView();//打开数据之后 初始化视图
private:
	Ui::MainWindow *ui;
	QSqlDatabase m_db;
	QSqlTableModel* m_model;
};


#endif //TEMPLATE_QT_MAINWINDOW_H
